package com.llk.data;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.json.JSONObject;
import android.util.Log;

import com.llk.data.bean.OrderBean;

public class OrderDetailImpl {
	
	public static JSONObject finishCode(String uuid,String code,String num){
		JSONObject jsonresult=new JSONObject();
		HttpClient httpClient = new DefaultHttpClient();
		String url="http://saas.menpiao.so/yz/api/finish.jsp?code="+code+"&uuid="+uuid+"&num="+num;
		try{
			Log.d("URL", url);
			HttpGet get = new HttpGet(url);
			HttpResponse response = httpClient.execute(get);
			String resultString = EntityUtils.toString(response.getEntity());
			jsonresult= new JSONObject(resultString);
		}catch(Exception e){
			e.printStackTrace();
		}
		return jsonresult;
	}

	public static JSONObject getOrderDetailById(String uuid,String order_password,String mode) {
		JSONObject jsonresult=new JSONObject();
		HttpClient httpClient = new DefaultHttpClient();
		String url="http://saas.menpiao.so/yz/api/query.jsp?code="+order_password+"&uuid="+uuid+"&mode="+mode;
		try{
			Log.d("URL", url);
			HttpGet get = new HttpGet(url);
			HttpResponse response = httpClient.execute(get);
			String resultString = EntityUtils.toString(response.getEntity());
			Log.d("result", resultString);
			jsonresult= new JSONObject(resultString);
		}catch(Exception e){
			e.printStackTrace();
		}
		return jsonresult;
	}

	public static boolean setDeviceId(String uuid, String code) {
		boolean res=false;
		HttpClient httpClient = new DefaultHttpClient();
		String url="http://saas.menpiao.so/yz/api/setDevice.jsp?id="+code+"&uuid="+uuid;
		try{
			Log.d("URL", url);
			HttpGet get = new HttpGet(url);
			HttpResponse response = httpClient.execute(get);
			String resultString = EntityUtils.toString(response.getEntity());
			JSONObject jsonresult= new JSONObject(resultString);
			Log.d("json", jsonresult.toString());
			res=jsonresult.optBoolean("res");
		}catch(Exception e){
			e.printStackTrace();
		}
		return res;
	}

}